#include <string>
#include <iostream>

using namespace std;

int main()
{
    int n;
    string str;
    cin >> n >> str;
    long long s = 0, y = 0, h = 0, ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (str[i] == 's')s++;
        else if (str[i] == 'h')h += s;
        else if (str[i] == 'y')ans += h;
    }
    cout << ans << endl;
    return 0;
}